import { _decorator, Component, Node } from 'cc';
import { PlayerState } from './PlayerState';
import { StateDefine } from '../../Config';
const { ccclass, property } = _decorator;

@ccclass('PlayerWallJump')
export class PlayerWallJump extends PlayerState {
    time = null;
    onEnter() {
        super.onEnter();
        this.time = 0.3;
        this.player.setVelocity(-this.player.facingDir*this.player.MoveSpeed,this.player.JumpForce*0.8)
        
    }
    onExit() {
        super.onExit();
    }
    update(deltaTime: number) {
        super.update(deltaTime);
        this.time-=deltaTime;
        if(this.rb.linearVelocity.y<0){
            this.player.stateMgr.transit(StateDefine.Fall);
        }
        if(this.player.input.x!=0&&this.time<0){
            this.player.setVelocity(this.player.MoveSpeed*this.player.input.x*0.8,this.rb.linearVelocity.y)
        }
    }
    onDestory() { }

    canTransit(to: StateDefine): boolean {
        return true;
    }
}


